<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
    @cancel="handleCancel"
  >
    <a-card :bordered="false">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="编号">
                <a-input placeholder="请输入编号" v-model="queryParam.code"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="名称">
                <a-input placeholder="请输入名称" v-model="queryParam.name"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- 查询区域-END -->
      <!-- table区域-begin -->
      <div>
        <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
          style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </div>

        <j-vxe-table
          keep-source
          ref="orderTable"
          :loading="loading"
          :columns="columns"
          :dataSource="dataSource"
          :maxHeight="300"
          @selectRowChange="onSelectRowChange"
          :rowNumber="true"
          :rowSelection="true"
          :toolbar="false"
        />
      </div>
    </a-card>
  </j-modal>
</template>

<script>
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@/api/manage'

export default {
  name: 'SelectProcurementModal',
  components: {},
  props:{
    supplierName: {          // 接收查询条件
      type: String,
      required: true
    }
  },
  mixins: [JVxeTableModelMixin, JeecgListMixin],
  data() {
    return {
      title: '选择采购订单',
      width: 600,
      visible: false,
      loading: false,
      dataSource: [],
      selectedRows: [],
      url: {
        list: '/procurement/bussMaterialProcurementContractReview/list'
      },
      columns: [
        {
          title: '合同审批单号',
          key: 'code',
          type: JVXETypes.normal,
          width: '150px'
        },
        {
          title: '供应商名称',
          key: 'supplierName',
          type: JVXETypes.normal,
          width: '300px'
        },
        {
          title: '采购合同名称',
          key: 'name',
          type: JVXETypes.normal,
          width: '100px'
        },
        {
          title: '制单人',
          key: 'createBy',
          type: JVXETypes.normal,
          width: '100px'
        },

        {
          title: '制单部门',
          key: 'sysOrgCode',
          type: JVXETypes.normal,
          width: '100px'
        },
        {
          title: '制单日期',
          key: 'createTime',
          type: JVXETypes.normal,
          width: '150px'
        },
        {
          title: '备注',
          key: 'remark',
          type: JVXETypes.normal,
          width: '150px'
        }
      ],
      disableSubmit: false
    }
  },
  created(){
    this.queryParam.status=999
  },
  methods: {
    onSelectRowChange({ type, action, selectedRows, $event }) {
      this.selectedRows = selectedRows
    },
    add() {
      this.visible = true
      this.loading = true
      var params = this.getQueryParams()
      console.log("ssssssssssssssssss",this.supplierName)
      params.supplierName=this.supplierName
      params.pageSize = 1000
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records || res.result
          if (res.result.total) {
            this.ipagination.total = res.result.total
          } else {
            this.ipagination.total = 0
          }
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.$emit('orderOk', this.selectedRows)
      this.visible = false
    },
    submitCallback() {
      this.$emit('ok')
      this.visible = false
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style scoped></style>
